package kr.hkit.androidcomplete02.ch11;

import kr.hyunist.androidcomplete01.*;
import android.app.*;
import android.graphics.*;
import android.os.*;
import android.widget.*;
import android.widget.RadioGroup.OnCheckedChangeListener;

public class RadioCheck extends Activity {
	TextView mText;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.radiocheck);
	
		mText = (TextView) findViewById(R.id.ch11_txtsample);
		RadioGroup colGroup = (RadioGroup) findViewById(R.id.ch11_colorgroup);
		colGroup.setOnCheckedChangeListener(mRadioCheck);
		
		CheckBox chkWhite = (CheckBox) findViewById(R.id.ch11_chkwhiteback);
		ToggleButton tglLang = (ToggleButton) findViewById(R.id.ch11_tgllanguage);
		
		chkWhite.setOnCheckedChangeListener(mListener);
		tglLang.setOnCheckedChangeListener(mListener);
	}
	
	OnCheckedChangeListener mRadioCheck = new OnCheckedChangeListener() {
		
		@Override
		public void onCheckedChanged(RadioGroup group, int checkedId) {
			if(group.getId() == R.id.ch11_colorgroup){
				switch(checkedId){
				case R.id.ch11_rared:
					mText.setTextColor(Color.RED);
					break;
				case R.id.ch11_ragreen:
					mText.setTextColor(Color.GREEN);
					break;
				case R.id.ch11_rablue:
					mText.setTextColor(Color.BLUE);
					break;	
				}
			}
			
		}
	};
	
	CompoundButton.OnCheckedChangeListener mListener = new CompoundButton.OnCheckedChangeListener() {
		
		@Override
		public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
			if(buttonView.getId()  == R.id.ch11_chkwhiteback){
				mText.setBackgroundColor(Color.BLACK);
			} else {
				mText.setBackgroundColor(Color.TRANSPARENT);
			}
			
			if(buttonView.getId() == R.id.ch11_tgllanguage){
				mText.setText("샘플");
			} else {
				mText.setText("Sample");
			}
		}
	};
	
	
}
